package ACWing.TheNnderlyingAlgorithm.前缀差分;
//795. 前缀和

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/11/17 17:16
 */
public class Prefix {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[]arr=new int[n+1];
        int[]sum=new int[n+1];
        int[][]q=new int[m][2];
        for (int i = 1; i <= n; i++) {
            arr[i]=sc.nextInt();
            sum[i]=sum[i-1]+arr[i];

        }
        for (int i = 0; i < m; i++) {
            q[i][0]=sc.nextInt();
            q[i][1]=sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            System.out.println(sum[q[i][1]]-sum[q[i][0]-1]);
        }
    }

}
